package br.org.demolay;

import java.util.List;

import br.org.demolay.webservice.Contato;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class ContatoAdapter extends ArrayAdapter<Contato> {

	private Context context;
	private List<Contato> values;

	public ContatoAdapter(Context context, List<Contato> values) {
		super(context, R.layout.contato_sub_item, values);
		this.context = context;
		this.values = values;
	}
	
	@Override
	  public View getView(int position, View convertView, ViewGroup parent) {
	    LayoutInflater inflater = (LayoutInflater) context
	        .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	    View rowView = inflater.inflate(R.layout.contato_sub_item, parent, false);
	    TextView nomeView = (TextView) rowView.findViewById(R.id.nome);
	    TextView emailView = (TextView) rowView.findViewById(R.id.email);
	    TextView telefoneView = (TextView) rowView.findViewById(R.id.telefone);
	    TextView celularView = (TextView) rowView.findViewById(R.id.celular);
	    nomeView.setText(values.get(position).getNome());
	    emailView.setText(values.get(position).getEmail());
	    telefoneView.setText(values.get(position).getTelefone());
	    celularView.setText(values.get(position).getCelular());
	    return rowView;
	  }

}
